<p>　</p>
<form  method="post" action="">
	<div id="uploader">
		<p>Your browser doesn't have Flash, Silverlight, Gears, BrowserPlus or HTML5 support.</p>
	</div>
</form>
<script type="text/javascript">
// Convert divs to queue widgets when the DOM is ready
$(function() {
	$("#uploader").plupload({
		// General settings
		runtimes : 'html5,flash,browserplus,silverlight,gears,html4',
		url : '<?php echo $ulpoad_url; ?>',
		max_file_size : '10mb',
		max_file_count: 5, // user can add no more then 5 files at a time
		chunk_size : '1mb',
		rename: true,
		multiple_queues : true,

		// Resize images on clientside if we can
		//resize : {width : 320, height : 240, quality : 90},
		
		// Rename files by clicking on their titles
		rename: true,
		
		// Sort files
		sortable: true,

		// Specify what files to browse for
		filters : [
			{title : "Image files", extensions : "jpg,gif,png"},
			{title : "Zip files", extensions : "zip,avi,pdf"}
		],

		// Flash settings
		flash_swf_url : '<?php echo $this->config->item('static_url'); ?>jscript/plupload/plupload.flash.swf',

		// Silverlight settings
		silverlight_xap_url : '<?php echo $this->config->item('static_url'); ?>jscript/plupload/plupload.silverlight.xap'
	});

	// Client side form validation
	$('form').submit(function(e) {
        var uploader = $('#uploader').plupload('getUploader');

        // Files in queue upload them first
        if (uploader.files.length > 0) {
            // When all files are uploaded submit form
            uploader.bind('StateChanged', function() {
                if (uploader.files.length === (uploader.total.uploaded + uploader.total.failed)) {
                    $('form')[0].submit();
                }
            });
                
            uploader.start();
        } else
            alert('You must at least upload one file.');

        return false;
    });
	 

});
</script>